#!/bin/bash
#
#	/etc/rc.d/init.d/website
#
# Starts the QA website
#
# chkconfig: 345 44 56
# description: Run the pycopia web framework.
# processname: websitectl

# Source function library.
. /etc/rc.d/init.d/functions

[ -x /usr/bin/websitectl ] || exit 0

RETVAL=0


start() {
	# Check if it is already running
	if [ ! -f /var/lock/subsys/website ]; then
	    echo -n $"Starting website: "
	    /usr/bin/websitectl start
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/website
	    echo
	fi
	return $RETVAL
}

stop() {
	echo -n $"Stopping website: "
	websitectl stop
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/website
	echo
        return $RETVAL
}


restart() {
	stop
	start
}	

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
restart)
	restart
	;;
condrestart)
	if [ -f /var/lock/subsys/website ]; then
	    restart
	fi
	;;
status)
	status website
	;;
*)
	echo $"Usage: $0 {start|stop|status|restart|condrestart}"
	exit 1
esac

exit $RETVAL
